package com.wenwei.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wenwei.bean.WalletHisBean;
import com.wenwei.parking.R;
import com.wenwei.utils.RogerDateUtils;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/21.
 */
public class BalanceAdapter extends RecyclerView.Adapter<BalanceAdapter.MyViewHolder> {

    private List<WalletHisBean.DataBean> mList;

    public void setmList(List<WalletHisBean.DataBean> list) {
        this.mList = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_balance, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        if(mList.get(position).getType() == 1){
            holder.itemBalanceName.setText("充值");
            holder.itemBalancePrice.setText("+"+mList.get(position).getAmount());
        }else {
            holder.itemBalanceName.setText("订单支付");
            holder.itemBalancePrice.setText("-"+mList.get(position).getAmount());
        }
        holder.itemBalanceTime.setText(RogerDateUtils.getDateToLongString(mList.get(position).getCreatedTime()));
    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder {

        @Bind(R.id.item_balance_name)
        TextView itemBalanceName;
        @Bind(R.id.item_balance_time)
        TextView itemBalanceTime;
        @Bind(R.id.item_balance_price)
        TextView itemBalancePrice;
        public MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }


}
